package com.kunyi.web.service.log.core.transform;

import com.kunyi.platform.log.entity.dto.SaveOpsDto;
import com.kunyi.web.service.log.entity.domain.LogOps;
import com.kunyi.web.service.log.entity.resp.LogOpsDetailResp;
import com.kunyi.web.service.log.entity.resp.LogOpsListResp;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @ClassName LogOpsTransform
 * @Description log_ops相关对象转换
 * @Author pengjunjun
 * @Date 2024/3/6 16:16
 * @Version 1.0
 **/
public class LogOpsTransform {

    /**
     * @return LogOpsListResp
     * @Author pengjunjun
     * @Description LogOps -> LogOpsListResp
     * @Date 16:28 2024/3/6
     * @Param logOps:
     **/
    public static LogOpsListResp log2ListResp(LogOps logOps) {
        return new LogOpsListResp()
                .setId(logOps.getId().toString())
                .setCode(logOps.getCode())
                .setIp(logOps.getIp())
                .setOpsObject(logOps.getOpsObject())
                .setOpsType(logOps.getOpsType())
                .setMethod(logOps.getMethod())
                .setStatus(logOps.getStatus())
                .setConsumeTime(logOps.getConsumeTime())
                .setSource(logOps.getSource())
                .setCreateUser(logOps.getCreateUser())
                .setCreateTime(logOps.getCreateTime());
    }

    /**
     * @Author pengjunjun
     * @Description LogOps -> LogOpsDetailResp
     * @Date 16:55 2024/3/6
     * @Param logOps:
     * @return LogOpsDetailResp
     **/
    public static LogOpsDetailResp log2DetailResp(LogOps logOps) {
        return new LogOpsDetailResp()
                .setCode(logOps.getCode())
                .setOpsObject(logOps.getOpsObject())
                .setOpsType(logOps.getOpsType())
                .setMethod(logOps.getMethod())
                .setUrl(logOps.getUrl())
                .setIp(logOps.getIp())
                .setStatus(logOps.getStatus())
                .setSource(logOps.getSource())
                .setConsumeTime(logOps.getConsumeTime())
                .setCreateUser(logOps.getCreateUser())
                .setCreateTime(logOps.getCreateTime())
                .setHeader(logOps.getHeader())
                .setParam(logOps.getParam())
                .setResponse(logOps.getResponse())
                ;
    }

    /**
     * @Author pengjunjun
     * @Description SaveOpsDto -> LogOps
     * @Date 15:07 2024/3/9
     * @Param saveOps:
     * @return LogOps
     **/
    public static LogOps save2Log(SaveOpsDto saveOps) {
        LogOps logOps = new LogOps();
        logOps.setCode(saveOps.getCode());
        logOps.setIp(saveOps.getIp());
        logOps.setOpsObject(saveOps.getOpsObject());
        logOps.setOpsType(saveOps.getOpsType());
        logOps.setMethod(saveOps.getMethod());
        logOps.setStatus(saveOps.getStatus());
        logOps.setConsumeTime(saveOps.getConsumeTime());
        logOps.setSource(saveOps.getSource());
        logOps.setUrl(saveOps.getUrl());
        logOps.setHeader(saveOps.getHeader());
        logOps.setParam(saveOps.getParam());
        logOps.setResponse(saveOps.getResponse());
        logOps.setContent(saveOps.getContent());
        return logOps;
    }
}
